<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\api\controller\shop;

use app\api\controller\shop\Base;
use think\Cache;

/**
 * @title 【会员基类】
 */
class Admin extends Base {

    /**
     * @title init
     */
    public function _initialize() {
        parent::_initialize();


        //从header中获取上面两个参数
        $header = request()->header();


        $token = isset($header['tk-token']) ? $header['tk-token'] : '';

        //
        if ($token) {

            $uid = Cache::get($token);  //nari10ims3ooo 仅用于测试环境

            if (is_numeric($uid)) {


                define('UID', $uid);


                return ['code' => 0, 'msg' => 'success'];
            } else {

                define('UID', 0);

                exit(json_encode(['code' => -1, 'msg' => 'access denied']));
            }
        } else {

            define('UID', 0);

            exit(json_encode(['code' => -1, 'msg' => 'params missing']));
        }
    }

}
